package com.five.taotao.order_details;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.five.taotao.R;
import com.five.taotao.product_details.ProductDetailsActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class OrderDetailActivity extends AppCompatActivity {

    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.quxiao)
    Button quxiao;
    @BindView(R.id.fukuan)
    Button fukuan;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_detail);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.back, R.id.quxiao, R.id.fukuan})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                Intent intent=new Intent(OrderDetailActivity.this, ProductDetailsActivity.class);
                startActivity(intent);
                break;
            case R.id.quxiao:
                final AlertDialog.Builder dialog= new AlertDialog.Builder(this);
                LayoutInflater inflater =LayoutInflater.from(this);
                View v = inflater.inflate(R.layout.alert, null, false);
                dialog.setView(v);
//              View v=  LayoutInflater.from(this).inflate(R.layout.alert,null,false);
//               v.findViewById(R.id.queren).setOnClickListener(new View.OnClickListener() {
//                   @Override
//                   public void onClick(View v) {
//                       Toast.makeText(OrderDetailActivity.this, "交易取消。", Toast.LENGTH_SHORT).show();
//                   }
//               });
//                v.findViewById(R.id.quxiao).setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//
//                    }
//                });
                dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(OrderDetailActivity.this,"交易取消。",Toast.LENGTH_SHORT).show();
                    }
                });
                dialog.show();
                break;
            case R.id.fukuan:
                break;
        }
    }
}
